package com.otheima.homeweek;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Demo05 {//键盘录你的入生日 (xxxx-xx-xx)计算你活了多少天？(方法二)

    public static void main(String[] args) {
        //录入生日
        System.out.println("请输入您的生日,请按xxxx-xx-xx的格式输入");
        String s = new Scanner(System.in).nextLine();

        //格式化
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        s += " 00:00:00";
        LocalDateTime localDateTime2 = LocalDateTime.parse(s, pattern);

        //查看间隔
        LocalDateTime localDateTime1 = LocalDateTime.now();
        Duration between = Duration.between(localDateTime2, localDateTime1);
        System.out.println("您活了"+between.getSeconds()/(60*60*24));
    }
}
